#!/usr/bin/env python

import cv2   as cv
import numpy as ny
import sys

'''
说明：imread()使用BRG方式读取一张图片，再通过cvtColor转换成GRAY格式，最终通过imwrite()输出保存
用法：./01_read_and_write_picture.py  [picture_path]
'''

print 'opencv version is :',cv.__version__

if len(sys.argv)<2:
	print('error,please input image path')

in_image = cv.imread(sys.argv[1],cv.IMREAD_COLOR)

out_image = cv.cvtColor(in_image,cv.COLOR_BGR2GRAY)

cv.imshow('in_image',in_image)
cv.imshow('out_image',out_image)
cv.imwrite('out_gray.jpg',out_image)

cv.waitKey(0)

